package com.changhai.diabetes.service.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.changhai.diabetes.model.Patient;
import com.changhai.diabetes.model.QueryDTO;
import com.changhai.diabetes.model.ResearchGroup;
import com.changhai.diabetes.model.page.Page;
import com.changhai.diabetes.model.page.Pagination;
import com.changhai.diabetes.service.SearchService;
import com.changhai.diabetes.util.Constants;

/**
 * 检索
 * 
 * @author Andy
 * 
 */
public class SearchServiceImpl extends CommonServiceImpl implements SearchService {
	
	public Page<?> searchQuery(QueryDTO queryDTO) {
		List<Patient> result = new ArrayList<Patient>();		 
		return new Pagination(new Integer(0), result, queryDTO.getConditions());
	}
	
	public List<Patient> getPatientIdsBySearch(Map<String, Object> map) {
		List<Long> patientIds = new ArrayList<Long>();
		List<Patient> result = new ArrayList<Patient>();
		if (map != null) {
			String s1 = (String) map.get("table");
			String s3 = (String) map.get("condition");
			if (s3.equals("searchType1")) {
				patientIds = this.getList(Constants.DS_CHANGHAI, "search.getPatientIdsByScope", map);
			} else if (s3.equals("searchType2")) {
				patientIds = this.getList(Constants.DS_CHANGHAI, "search.getPatientIdsBySpec", map);
			} else if(s1.indexOf("lab_pancreat")!=-1){
				patientIds = this.getList(Constants.DS_CHANGHAI, "search.getPatientIdsForPancreat", map);
			} else {
				patientIds = this.getList(Constants.DS_CHANGHAI, "search.getPatientIds", map);
			}
		}

		if (patientIds != null && patientIds.size() > 0) {
			result = this.getList(Constants.DS_CHANGHAI, "search.getByPatientIds", patientIds);
		}
		return result;
	}
}
